package com.czxy.changgou4.pojo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 桐叔
 * @email liangtong@itcast.cn
 */
@TableName("tb_category")
@Data
public class Category {
    private Integer id;
    private String catName;         //分类名称
    private Integer parentId;       //父分类的id
    private Boolean isParent;       //是否是父分类

    // 一个一级分类，可以存放 多个二级分类
    @TableField( exist =  false)
    @JsonInclude(JsonInclude.Include.NON_EMPTY)     //转换成json时，包含非空项
    private List<Category> categoryList = new ArrayList<>();
}

/*
CREATE TABLE `tb_category` (
  `id` bigint(20) NOT NULL,
  `cat_name` varchar(20) DEFAULT NULL,
  `parent_id` bigint(20) DEFAULT NULL,
  `is_parent` int(1) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
 */
